#include "Menu.hpp"

Menu::Menu() {
    this->options = new vector<MenuEntry*>();
    this->selectedOption = 0;
}

Menu::~Menu() {
    for (vector<MenuEntry*>::iterator i = this->options->begin(); i != this->options->end(); ++i) {
        delete *i;
    }

    delete this->options;
}

bool Menu::isMainMenu() {
    return false;
}

void Menu::next() {
    ++this->selectedOption;

    if ((unsigned)this->selectedOption == this->options->size()) {
        this->selectedOption = 0;
    }
}

void Menu::previous() {
    --this->selectedOption;

    if (this->selectedOption == -1) {
        this->selectedOption = this->options->size() - 1;
    }
}

// Menu::MenuEntry

Menu::MenuEntry::MenuEntry(string id, string label) {
    this->id = new string(id);
    this->label = new string(label);
}

Menu::MenuEntry::~MenuEntry() {
    delete this->id;
    delete this->label;
}
